﻿using FastCloud.Base.Desgin;
using FastCloud.Extend.Entity;
using FastUtil.Data;
using System;
using System.Collections.Generic;
using System.Text;

namespace FastCloud.Extend.DB
{
    public class DB_ElementRight : BaseCacheML<Frame_ElementRight>
    {
        public override void Insert(Frame_ElementRight Entity)
        {
            if (string.IsNullOrEmpty(Entity.RelationGuid))
            {
                Entity.RelationGuid = GenerateUtil.GenerateUnitGuid();
            }
            Entity.AddDate = DateTime.Now;
            base.Insert(Entity);
        }

        public List<Frame_ElementRight> SelectAll()
        {
            return DTO.Select_Cache<Frame_ElementRight>(); ;
        }

        public void DeleteByElementGuid(string ElementGuid)
        {
            List<Frame_ElementRight> MenuRightList = SelectAll().FindAll(a => a.ElementGuid == ElementGuid);
            foreach (Frame_ElementRight right in MenuRightList)
            {
                DeleteByID(right.RelationGuid);
            }
        }
    }
}
